﻿/**
 * http://www.kahrel.plus.com/indesign/scriptui-1-5.pdf
 */

#include "scriput-ui.jsx"

var comment_obj = {
    "comment": "Ctrl+Enter で改行です!!"
};

var LAYOUT = {
    "type": "panel",
    "child": {
        
        "type-input": {
            "type": "group",
            "child": {
                "label"     : { "type":"statictext", "text": "Type : " },
                "listbox"   : {
                    "type": "dropdownlist",
                    "text": ["", "Null", "Sprite", "Text", "TextTextTextTextTextText"],
                    "characters":20,
                    "selection": 1,
                    "change"     : function() { alert(this.selection); }
                }
            }
        },
        
        "dummy0-input": {
            "type": "group",
            "child": {
                "key"   : { "type": "statictext", "text": "type: " },
                "input" : { "type": "edittext", "text": "abc", "characters":20 }
            }
        },
        "comment-input": {
            "type": "group",
            "child": {
                "key"   : { "type": "statictext", "text": "comment: " },
                "input" : {
                    "type"      : "edittext",
                    "text"      : "hoge",
                    "bounds"    : [0, 0, 200, 70],
                    "property"  : { "multiline": true, "scrolling":true},
                    "alignment" : ["fill", "fill"],
                    "change"     : function(e) { 
                        comment_obj["comment"] = this.text;
                        // alert(e.target);
                    }
                }
            }
        },
        "dummy-radiobutton": {
            "type": "group",
            "child": {
                "key"   : { "type":"statictext", "text": "radio-sample: " },
                "item0" : { "type":"radiobutton", "text":"item0" },
                "item1" : { "type":"radiobutton", "text":"item1" },
                "item2" : { "type":"radiobutton", "text":"item2" },
            }
        },
        "dummy-listbox": {
            "type": "group",
            "child": {
                "key"       : { "type":"statictext", "text": "listbox-sample: " },
                "listbox"   : {
                    "type": "listbox",
                    "text": ["one", "two", "three"],
                    "selection": 1,
                    "change"     : function() { alert(this.selection); }
                }
            }
        },
        
        "dummy-dropdownlist": {
            "type": "group",
            "child": {
                "key"       : { "type":"statictext", "text": "dropdownlist-sample: " },
                "listbox"   : {
                    "type": "dropdownlist",
                    "text": ["one", "two", "three"],
                    "selection": 1,
                    "change"     : function() { alert(this.selection); }
                }
            }
        },
        
        "output-path": {
            "type": "group",
            "child": {
                "label"     : { "type":"statictext", "text": "出力先: " },
                "input" : {
                    "type"      : "edittext",
                    "text"      : "c:/",
                    "characters":20,
                    "change"     : function(e) { 
                        alert(e.target.text);
                    },
                    "shortcutKey": "s",
                },
                "iconbutton": {
                    "type"      : "iconbutton",
                    "text"      : "#FolderOpened",
                }
            }
        },
        
        "button": {
            "type": "button",
            "text": "Save",
            // "property": {name:"ok"}
            "click": function() { $.writeln("click"); }
        },
    }
};

(function(){
    
    var myWindow = new Window("dialog", "Comment Form", undefined, {"resizeable":true} );
    UI.create(myWindow, LAYOUT, "panel");
    
    myWindow["panel"]["comment-input"]["input"].text = comment_obj["comment"];
    
    myWindow.show();
    
})();

$.writeln(comment_obj.toSource());

